<template>
	<view class="">
		<view class="image">
			<image @longpress="toSave" :src="info.img" mode="widthFix" style="width: 100%;"></image>
		</view>
		<bot-tomtab/>
	</view>
</template>

<script>
	import BotTomtab from '@/components/bottomtab.vue';
	export default {
		data() {
			return {
				info: ""
			}
		},
		components: {
			BotTomtab
		},
		onLoad(option) {
			var that = this;
			that.$axios('Shares/main', "POST", 'commission', {

			}).then(res => {
				if (res.data.code == 200) {
					that.info = res.data.data
				}
			}, (error) => {

			})
		},
		methods: {
			// 长按保存图片
			toSave() {
				var that = this;
				uni.showModal({
					title: '图片保存',
					content: '确定要保存图片吗',
					success: e => {
						if (e['confirm']) {
							uni.downloadFile({
								url: that.info.img,
								success: function(url) {
									uni.saveImageToPhotosAlbum({
										filePath: url.tempFilePath,
										success: function(e) {
											uni.showToast({
												title: '图片保存成功',
												icon: 'none',
												duration: 2200
											});
										},
									});
								},
								fail(e) {
									console.log(e)
								}
							});
						}
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	page {
		padding-bottom: 180upx;
	}

	.image {
		font-size: 0;
		height: 100%;
	}
</style>
